CC = gcc
CFLAGS = -g -Wall
# mysql_config --cflags = -I/usr/include/mysql -DBIG_JOINS=1 -fPIC -fno-strict-aliasing -DUNIV_LINUX
CFLAGS_DB = -g -Wall `mysql_config --cflags`
# mysql_config --libs = -Wl,-Bsymbolic-functions -rdynamic -L/usr/lib/mysql -lmysqlclient
LIBS = -lpthread `mysql_config --libs`

all: debug/test_server
debug/test_server:	debug/server_main.o	debug/chatter_err_log.o	debug/passive_tcp.o	debug/chatter_serv.o	debug/md5.o
	$(CC) $(LIBS) -o $@ \
		debug/server_main.o debug/chatter_err_log.o debug/passive_tcp.o debug/chatter_serv.o debug/md5.o

debug/server_main.o:	server_main.c	passive_tcp.h	chatter_err_log.h	chatter_serv.h
	$(CC) $(CFLAGS_DB) -c -o $@ server_main.c

debug/chatter_err_log.o:	chatter_err_log.h	chatter_err_log.c
	$(CC) $(CFLAGS) -c -o $@ chatter_err_log.c

debug/passive_tcp.o:	passive_tcp.h	passive_tcp.c	chatter_err_log.h
	$(CC) $(CFLAGS) -c -o $@ passive_tcp.c

debug/chatter_serv.o:	chatter_serv.c	chatter_serv.h	chatter_err_log.h	chatter_global.h md5.h
	$(CC) $(CFLAGS_DB) -c -o $@ chatter_serv.c

debug/md5.o:	md5.c	md5.h
	$(CC) $(CFLAGS) -c -o $@ md5.c

clean:
	-rm debug/*.o
